#include "donsee.h"
#include <unistd.h>

int main()
{
	long t_nHandle;
	int i = 0;
	char pszError[128];
	unsigned char Response[1024] = {0};
	long t_nRe;

	t_nHandle = Donsee_Open("USB");
	if (t_nHandle != 0)
	{

		printf("打开设备失败，t_nRe = %ld\n", t_nHandle);
		return -1;
	}

	printf("打开设备成功，t_nRe = %ld\n", t_nHandle);

    char t_szBankNo[128] = "" ;
    char *p,*q;
    unsigned char tmp;
    for (; ;)
	{
		memset(t_szBankNo,0,128) ;
		t_nRe = Donsee_GetBankCardNo(t_szBankNo) ;
		if(t_nRe != 0)
			printf("读取银行卡号失败\n") ;
		else
        {
            tmp = (unsigned char)(strchr(t_szBankNo, 'D')-t_szBankNo);
            q = (tmp > 0)?strndup(t_szBankNo, tmp):strdup(t_szBankNo);

			printf("读取银行卡号成功：%s\n",q) ;
        }

        
        usleep(1000*1000) ;
	}



	Donsee_Close();

}